/**
 * 图表自定义指令和服务
 * @author Peter
 * @Date 2016-5-25
 */
angular.module('mamApp').directive('chart', ['$state', function ($state) {
    return {
        restrict: 'A',
        replace: false,
        scope: {
            chart: '=',
            init: '@'
        },
        link: function (scope, element, attrs) {
            var chart = echarts.init($(element).get(0));

            scope.$watch('chart', function (newValue, oldValue) {
                if (newValue) {
                    chart.setOption(newValue)
                }
            }, true)
           
        }
    };
}]);
